local renwu = fk.CreateSkill {
  name = "ls__renwu",
}

Fk:loadTranslationTable{
  ["ls__renwu"] = "刃舞",
  [":ls__renwu"] = "回合结束时，若你于此回合对至少两名角色造成过伤害，你可对这些角色各造成1点伤害。",
  ["@[player]renwu-turn"] = "刃舞",

  ["$ls__renwu1"] = "叛夫小儿，快快授首！",
  ["$ls__renwu2"] = "前军待阵，袭杀逆贼。",
}

renwu:addEffect(fk.TurnEnd, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(renwu.name) then
      local victims = {}
      player.room.logic:getActualDamageEvents(1, function (e)
        if (e.data.from and e.data.from == player) then
          table.insertIfNeed(victims, e.data.to.id)
        end
      end, Player.HistoryTurn)
      return #victims >= 2
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "@[player]renwu-turn", 0)
    local victims = {}
    player.room.logic:getActualDamageEvents(1, function (e)
      if (e.data.from and e.data.from == player) then
        table.insertIfNeed(victims, e.data.to)
      end
    end, Player.HistoryTurn)
    for _, p in pairs(victims) do
      player.room:damage{
        from = player,
        to = p,
        damage = 1,
        skillName = renwu.name,
      }
    end
  end,
})

renwu:addEffect(fk.Damage, {
  anim_type = "offensive",
  can_refresh = function(self, event, target, player, data)
    if target == player and player:hasSkill(renwu.name) then
      return player.room.current == player and not table.contains(player:getTableMark("@[player]renwu-turn"), data.to.id)
    end
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:addTableMarkIfNeed(player, "@[player]renwu-turn", data.to.id)
  end,
})

return renwu